package com.longge;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-04-13 02:24
 */
public class RemoveElements {

    public ListNode removeElements(ListNode head, int val) {

        ListNode dum = new ListNode(-1), pre = dum;
        dum.next = head;
        while (pre.next != null) {
            if (pre.next.val == val) {
                pre.next = pre.next.next;
            } else {
                pre = pre.next;
            }
        }
        return dum.next;

    }
}
